import { INestApplication } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AdminModule } from './admin/admin.module';
import { WeappModule } from './weapp/weapp.module';
import { NotifyModule } from './notify/notify.module';
import { AgentModule } from './agent/agent.module';

export function ApiSwaggerSetup(app: INestApplication) {
  const adminConfig = new DocumentBuilder()
    .setTitle('Admin API')
    .setDescription('API for admin')
    .setVersion('1.0')
    .addTag('auth', '认证')
    .build();

  const weappConfig = new DocumentBuilder()
    .setTitle('Weapp API')
    .setDescription('API for weapp')
    .setVersion('1.0')
    .addTag('auth', '认证')
    .build();

  const agentConfig = new DocumentBuilder()
    .setTitle('Agent API')
    .setDescription('API for agent')
    .setVersion('1.0')
    .addTag('profile', '信息')
    .addTag('user', '用户')
    .addTag('order', '订单')
    .build();

  const notifyConfig = new DocumentBuilder()
    .setTitle('Notify API')
    .setDescription('API for notify')
    .setVersion('1.0')
    .build();

  const adminDocument = SwaggerModule.createDocument(app, adminConfig, {
    include: [AdminModule],
  });

  const weappDocument = SwaggerModule.createDocument(app, weappConfig, {
    include: [WeappModule],
  });

  const agentDocument = SwaggerModule.createDocument(app, agentConfig, {
    include: [AgentModule],
  });

  const notifyDocument = SwaggerModule.createDocument(app, notifyConfig, {
    include: [NotifyModule],
  });
  SwaggerModule.setup('api/admin', app, adminDocument);
  SwaggerModule.setup('api/weapp', app, weappDocument);
  SwaggerModule.setup('api/agent', app, agentDocument);
  SwaggerModule.setup('api/notify', app, notifyDocument);
}
